﻿@model JuCheap.Core.Models.ViewModels.WorkerViewModel
@{
    ViewData["Title"] = "Add";
    Layout = "~/Views/Shared/_Layout_Content.cshtml";
}


<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5></h5>
            <div class="ibox-tools">
                <a class="collapse-link">
                    <i class="fa fa-chevron-up"></i>
                </a>
            </div>
        </div>
        <div class="ibox-content">
            <form id="uploadForm" asp-controller="Worker" asp-action="Add" class="form-horizontal" method="POST">


                <div class="form-group">
                    <label class="col-sm-3 control-label" asp-for="Name"></label>
                    <div class="col-sm-8">
                        <input asp-for="Name" class="form-control" placeholder="人员姓名" />
                        <span asp-validation-for="Name"></span>
                    </div>
                </div>
                <!--公司-->
                <div class="form-group">
                    <label class="col-sm-3 control-label" asp-for="CompanyId"></label>
                    <div class="col-sm-8">
                        <select id="CompanyId" name="CompanyId" class="form-control"></select>
                        <span asp-validation-for="CompanyId"></span>
                    </div>
                </div>
                <!--岗位类别-->
                <div class="form-group">
                    <label class="col-sm-3 control-label" asp-for="JobPositionTypeId"></label>
                    <div class="col-sm-8">
                        <select id="JobPositionTypeId" name="JobPositionTypeId" class="form-control"></select>
                        <span asp-validation-for="JobPositionTypeId"></span>
                    </div>
                </div>
                <!--岗位-->
                <div class="form-group">
                    <label class="col-sm-3 control-label" asp-for="JobPositionId"></label>
                    <div class="col-sm-8">
                        <select id="JobPositionId" name="JobPositionId" class="form-control"></select>
                        <span asp-validation-for="JobPositionId"></span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label" asp-for="ExtenralId"></label>
                    <div class="col-sm-8">
                        <input asp-for="ExtenralId" class="form-control" placeholder="第三方id" />
                        <span asp-validation-for="ExtenralId"></span>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label" asp-for="PhoneNumber"></label>
                    <div class="col-sm-8">
                        <input asp-for="PhoneNumber" class="form-control" placeholder="手机号" />
                        <span asp-validation-for="PhoneNumber"></span>
                    </div>
                </div>


                <div class="form-group">
                    <label class="col-sm-3 control-label" asp-for="NickName"></label>
                    <div class="col-sm-8">
                        <input asp-for="NickName" class="form-control" placeholder="昵称" />
                        <span asp-validation-for="NickName"></span>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label" asp-for="Birthday"></label>
                    <div class="col-sm-8">
                        <input asp-for="Birthday" class="form-control" placeholder="生日" />
                        <span asp-validation-for="Birthday"></span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label" asp-for="Email"></label>
                    <div class="col-sm-8">
                        <input asp-for="Email" class="form-control" placeholder="邮箱" />
                        <span asp-validation-for="Email"></span>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label" asp-for="Gender"></label>
                    <div class="col-sm-8">
                        <select id="Gender" name="Gender" class="form-control">
                            <option value="1" selected="selected">男</option>
                            <option value="0">女</option>
                        </select>
                        <span asp-validation-for="Gender"></span>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label" asp-for="CardType"></label>
                    <div class="col-sm-8">
                        <select id="CardType" name="CardType" class="form-control">
                            <option value="1" selected="selected">身份证</option>
                            <option value="0">其他</option>
                        </select>
                        <span asp-validation-for="CardType"></span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label" asp-for="CardNumber"></label>
                    <div class="col-sm-8">
                        <input asp-for="CardNumber" class="form-control" placeholder="证件号" />
                        <span asp-validation-for="CardNumber"></span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label" asp-for="Remark"></label>
                    <div class="col-sm-8">
                        <input asp-for="Remark" class="form-control" placeholder="工号" />
                        <span asp-validation-for="Remark"></span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label" asp-for="GroupIds"></label>

                    <div class="col-sm-8">
                        <select name="GroupIds" id="GroupIds"
                                class="form-control" placeholder="组"></select>
                        <span asp-validation-for="GroupIds"></span>
                    </div>
                    <span asp-validation-for="GroupIds"></span>

                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label" asp-for="Status"></label>
                    <div class="col-sm-8">
                        <select id="Status" name="Status" class="form-control">
                            <option value="1" selected="selected">驻场</option>
                            <option value="2">离场</option>
                        </select>
                        <span asp-validation-for="Gender"></span>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label" asp-for="UserHeadImageUrl"></label>
                    <div class="col-sm-8">
                        <button class="btn btn-success fileinput-button" type="button">上传</button>
                        <input type="file" id="UserHeadImageUrl" onchange="doUpload()" name="UserHeadImageUrl" style="position:absolute;top:0;left:0;font-size:34px; opacity:0">
                        @*<input type="file" class="file" id="UserHeadImageUrl" onchange="doUpload()" name="UserHeadImageUrl" />*@

                        @*<input type="button" value="上传" onclick="doUpload()" />*@
                        <input type="hidden" name="IdentificationHeadImageUrl" id="IdentificationHeadImageUrl" />
                        <img id="imgUserHeadImageUrl" />
                    </div>
                </div>


                <div class="form-group">
                    <div class="col-sm-offset-3 col-sm-8">
                        <button class="btn btn-info" type="submit">保存</button>
                        <button class="btn btn-white" type="button" id="btnBack">返回</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
@section styles{
    <link href="~/js/plugins/select2/css/select2.css" rel="stylesheet" />
}

@section scripts{
        <script src="~/js/jquery.validate.js"></script>
        <script src="~/js/jquery.validate.unobtrusive.js"></script>
        <script src="~/js/base.js"></script>
    <environment names="Staging,Production">
        <script src="~/js/validate.min.js" asp-append-version="true"></script>
        <script src="~/js/base.min.js" asp-append-version="true"></script>
    </environment>
    <script src="~/js/plugins/select2/js/select2.js"></script>
    <script src="~/js/BindSelect.js"></script>
    <script>
        $("#btnBack").bind("click", function (e) {
            XPage.GoTo(e.target, "@Url.Action("Index")");
        });

        function doUpload() {
          
            var formData = new FormData($("#uploadForm")[0]);
            $.ajax({
                url: "/FileUpload/OnPostUpload?handler=Upload",
                beforeSend: function (xhr) {
                    xhr.setRequestHeader("XSRF-TOKEN",
                        $('input:hidden[name="__RequestVerificationToken"]').val());
                },
                type: 'POST',
                data: formData,
                async: false,
                cache: false,
                contentType: false,
                processData: false,
                success: function (returndata) {
                    $("#imgUserHeadImageUrl").attr('src', '/upload/' + returndata);
                    $("#IdentificationHeadImageUrl").val(returndata);
                },
                error: function (returndata) {
                }
            });
        }
         
        BindSelectByValue("GroupIds", "/DepartmentGroup/GetDepartmentGroups", @Model.GroupIds);
        BindSelect("JobPositionTypeId", "/JobPositionType/GetJobPositionTypes");
        BindSelect("CompanyId", "/Company/GetCompanys");
        BindSelect("JobPositionId", "/JobPosition/GetJobPositions?jobTypeId=" + $("#JobPositionTypeId").val());



        $(function () {
            $('#JobPositionTypeId').change(function () {
                BindSelect("JobPositionId", "/JobPosition/GetJobPositions?jobTypeId=" + $("#JobPositionTypeId").val());
                //$("#JobPositionId").empty();
                //$('#JobPositionId').select2({
                //    placeholder: "岗位名称",
                //    ajax: {
                //        url: '/JobPosition/GetJobPositions?jobTypeId=' + $("#JobPositionTypeId").val(),
                //        dataType: 'json'
                //    }
                //});
            });
        });

        @*$(function() {
            $('#CompanyId').select2({
                placeholder: "公司",
                ajax: {
                   url: '@Url.Action("GetCompanys", "Company")',
                    dataType: 'json'
                }
            });
        });*@

    </script>
}



